package org.example.buffer;

import java.nio.ByteBuffer;

/**
 * 异常
 */
public class Demo2 {
    public static void main(String[] args) {
        //创建字节缓冲
        ByteBuffer intBuffer = ByteBuffer.allocate(5);
        //填入其他类型
        intBuffer.putShort((short) 1);
        //翻转
        intBuffer.flip();
        //获取,因为类型不一致,此时会抛出异常
        System.out.println(intBuffer.getLong());
    }
}
